package internet_06;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/*
    练习1：我有一个ArrayList<Integer>集合，现在我想在这个集合中添加一个字符串数据，如何实现？
 */
public class Demo01 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer> al = new ArrayList<>();
        al.add(20);
        al.add(50);
        al.add(30);
        al.add(40);

        Class<? extends ArrayList> c = al.getClass();

        Method m = c.getMethod("add", Object.class);

        m.invoke(al, "hello");

        System.out.println(al);


    }
}
